package com.example.esp32;
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
import org.eclipse.paho.client.mqttv3.MqttCallback;
import org.eclipse.paho.client.mqttv3.MqttMessage;

    public class SampleCallback implements MqttCallback {
        // 连接丢失
        public void connectionLost(Throwable cause) {
            System.out.println("connection lost：" + cause.getMessage());
        }

        //  收到消息
        public void messageArrived(String topic, MqttMessage message) {
            System.out.println("Received message: \n  topic：" + topic + "\n  Qos：" + message.getQos() + "\n  payload：" + new String(message.getPayload()));
        }

        // 消息传递成功
        public void deliveryComplete(IMqttDeliveryToken token) {
            System.out.println("deliveryComplete");
        }


    }
